(function () {
    window.Life = class Life {
        constructor () {
            this.leftLife = 5
            this.x = game.canvas.width -  5.2 * 30
            this.y = 10
            this.width = 30
            this.height = 30
        }
        lose () {
            this.leftLife --
            game.ball.reset()
            if (this.leftLife === 0) {
                game.over()
            }
        }
        add () {
            if (this.leftLife === 5) return
            this.leftLife ++
        }
        render () {
            for (var i = 0; i < this.leftLife;i++) {
                game.context.drawImage(game.images.life,0,0,256,256, this.x + i * this.width, this.y, this.width, this.height)
            }
        }
    }
})()